import Vue from 'vue'
import Router from 'vue-router'
import footer from '@/components/Footer/footer'
import header from '@/components/Header/header'
import side from '@/components/Side/side'

Vue.use(Router)

let router = new Router({
    routes: [{
            // 底部
            path: '/footer',
            name: 'footer',
            component: footer
        },
        {
            // 头部
            path: '/header',
            name: 'header',
            component: header
        },
        {
            // 侧边栏
            path: '/side',
            name: 'side',
            component: side
        },
        {
            // 关于我们
            path: '/about',
            name: 'about',
            component: () =>
                import ('@/pages/About/about')
        },
        {
            // 首页
            path: '/',
            name: 'home',
            component: () =>
                import ('@/pages/Home/home')
        },
        {
            // 蛋糕页
            path: '/cake',
            name: 'cake',
            component: () =>
                import ('@/pages/Cake/cake')
        },
        {
            // 巧克力页
            path: '/chocolates',
            name: 'chocolates',
            component: () =>
                import ('@/pages/Chocolates/chocolates'),
        },
        {
            // 详情页
            path: '/detail',
            name: 'detail',
            component: () =>
                import ('@/pages/Detail/detail')
        },
        {
            // 鲜花
            path: '/flower',
            name: 'flower',
            component: () =>
                import ('@/pages/Flower/flower')
        },
        {
            // 礼品页
            path: '/gifts',
            name: 'gifts',
            component: () =>
                import ('@/pages/Gifts/gifts')
        },
        {
            // 服务页
            path: '/help',
            name: 'help',
            component: () =>
                import ('@/pages/Help/help')
        },
        {
            // 花语页
            path: '/huayu',
            name: 'huayu',
            component: () =>
                import ('@/pages/Huayu/huayu')
        },
        {
            // 登录页
            path: '/login',
            name: 'login',
            component: () =>
                import ('@/pages/Login/login')
        },
        {
            // 会员页
            path: '/menberlenter',
            name: 'menberlenter',
            component: () =>
                import ('@/pages/Menberlenter/menberlenter')
        },
        {
            // 注册页
            path: '/reginster',
            name: 'reginster',
            component: () =>
                import ('@/pages/reginster/reginster')
        },
        {
            // 提交页
            path: '/sendinfo',
            name: 'sendinfo',
            component: () =>
                import ('@/pages/Sendinfo/sendinfo')
        },
        {
            // 购物车页
            path: '/shoppcar',
            name: 'shoppcar',
            component: () =>
                import ('@/pages/shoppcar/shoppcar')
        },
        {
            // 情人节页面
            path: '/valentine',
            name: 'valentine',
            component: () =>
                import ('@/pages/valentine/valentine')
        },
        {
            // 永生花页
            path: '/yongflower',
            name: 'yongflower',
            component: () =>
                import ('@/pages/Yongflower/yongflower')
        },
        {
            // 设计师页
            path: '/you',
            name: 'you',
            component: () =>
                import ('@/pages/You/you')
        },
        {
            // 会员中心页
            path: '/menberlenter',
            name: 'you',
            component: () =>
                import ('@/pages/Menberlenter/menberlenter')
        },
    ]
})
router.beforeEach((to, from, next) => {
    if (to.path == '/menberlenter') {
        if (sessionStorage.getItem("uname")) {
            next()
        } else {
            next({ path: "/login", name: "login" })
            alert("注册")
        }
    } else {
        next()
    }

})


export default router